import rollup from "rollup";
import nodeResolve from "rollup-plugin-node-resolve";
import sourcemaps from "rollup-plugin-sourcemaps";
import cjs from "rollup-plugin-commonjs";
import inject from "rollup-plugin-inject";
import json from "rollup-plugin-json";

/**
 * @type {rollup.RollupFileOptions}
 */
const config = {
  input: "./esm/batchIndex.js",
  external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
  output: {
    file: "./dist/batch.js",
    format: "umd",
    name: "Azure.Batch",
    sourcemap: true,
    globals: {
      "@azure/ms-rest-js": "msRest",
      "@azure/ms-rest-azure-js": "msRestAzure"
    },
    banner: `/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */`
  },
  plugins: [
    nodeResolve({ module: true, preferBuiltins: false }),
    sourcemaps(),
    cjs({
      namedExports: {
        "url-parse": ["url"],
        jssha: ["jssha"]
      }
    }),
    inject({
      modules: {
        Buffer: ["buffer", "Buffer"],
        process: "process"
      },
      exclude: ["./**/package.json"]
    }),

    json()
  ]
};

export default config;
